﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcs.Web.SupplyPlanSectionQRC
{
    public partial class ListSupplyPlanChoseQRC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "lbn_add")
            {
                Response.Redirect("SetProductionOrder.aspx?supplyPlanId="+e.CommandArgument);
            }
        }

        private void Bind()
        {
            string str = " 1=1 ";

            if (!string.IsNullOrEmpty(this.txt_projectName.Text))
            {
                str += " and projectName like '%"+ this.txt_projectName.Text + "%' " ;
            }
            if (!string.IsNullOrEmpty(this.txt_supplier.Text))
            {
                str +=   " and sname  like '%"+ this.txt_supplier.Text + "%' ";
            }
            if (!string.IsNullOrEmpty(txt_material.Text))
            {
                str += " and material like '%"+ this.txt_material.Text + "%'  " ;
            }
            if (!string.IsNullOrEmpty(txt_purchaseid.Text))
            {
                str += " and purchaseid = '" + this.txt_purchaseid.Text + "'  ";
            }

            if (!string.IsNullOrEmpty(txt_proid.Text))
            {
                str += " and proid = '" + this.txt_proid.Text + "'  ";
            }


            Maticsoft.BLL.supplyPlanOrderQRC sm = new Maticsoft.BLL.supplyPlanOrderQRC();

           
            DataSet ds = sm.GetListByPageSupplyPlan(str, "",
                this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize);

            this.AspNetPager1.RecordCount = sm.GetRecordCountSupplyPlan(str);

            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();


        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            Bind();
        }

        protected void btn_sel_Click(object sender, EventArgs e)
        {
            Bind();
        }
    }
}